<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:84:"/Applications/MAMP/htdocs/wifi/public/../application/admin/view/manager/addrole.html";i:1531800487;s:78:"/Applications/MAMP/htdocs/wifi/application/admin/view/common/login-layout.html";i:1531800487;s:72:"/Applications/MAMP/htdocs/wifi/application/admin/view/common/header.html";i:1531800487;s:72:"/Applications/MAMP/htdocs/wifi/application/admin/view/common/footer.html";i:1531800487;}*/ ?>
﻿<!DOCTYPE HTML>
<html>
    <head>
        <title><?=$seo['title']?$seo['title']:config('SITE_NAME')?></title>
        <meta charset="UTF-8">
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link href="/static/hui/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
        <link href="/static/hui/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
        <link href="/static/hui/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
        <link href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="/static/lib/jquery/1.9.1/jquery.min.js"></script> 
        <script type="text/javascript" src="/static/lib/layDate-v5.0.9/laydate/laydate.js"></script> 
        <link rel="Bookmark" href="<?=config('site_logo')?>" >
        <link rel="Shortcut Icon" href="<?=config('site_logo')?>" />
        <!--[if lt IE 9]>
        <script type="text/javascript" src="/lib/html5.js"></script>
        <script type="text/javascript" src="/lib/respond.min.js"></script>
        <![endif]-->
        <link rel="stylesheet" type="text/css" href="/static/hui/h-ui.admin/css/H-ui.admin.css" />
        <link rel="stylesheet" type="text/css" href="/static/hui/h-ui.admin/skin/default/skin.css" id="skin" />
        <!--[if IE 6]>
        <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
        <!--/meta 作为公共模版分离出去-->
    </head>
    <body>



 <article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form">
        <input type="hidden" class="input-text" value="<?php echo $role['id']; ?>" placeholder=""  name="id" >
        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>角色名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<?php echo $role['name']; ?>" placeholder="角色名称"  name="name" >
            </div>
        </div>
<!--        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>数据：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="radio-box">
                    <input type="radio" id="radio-1" value="0" name="readonly" <?php echo $role['readonly']?'':'checked' ?>>
                    <label for="radio-1">允许修改数据</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="radio-2" value="1" name="readonly" <?php echo $role['readonly']?'checked':'' ?>>
                    <label for="radio-2">不允许数据</label>
                </div>
            </div>
        </div>-->
<!--        <div class="row cl">
            <label class="form-label col-xs-2 col-sm-2">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="" name="">
            </div>
        </div>-->
        <div id="app" class="row cl">
            <label class="form-label col-xs-2 col-sm-2">网站角色：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <template v-for="(item,index) in menus">
                    <dl class="permission-list">
                        <dt>
                            <label style="display:none;">
                                <input type="checkbox"  v-model="item.checked" :value="item.id" name="menu[]" >
                                {{item.title}}
                            </label>
                        </dt>
                        <dd>
                            <dl class="cl permission-list2">
                                <dt>
                                    <label class="">
                                        页面
                                    </label>
                                </dt>
                                <dd>
                                    <template v-for="(citem,cindex) in levelList(index,2)">
                                        <label class="">
                                            <input v-model="citem.checked" type="checkbox" :value="citem.id" name="menu[]">
                                            {{citem.title}}
                                        </label>
                                    </template>
                                </dd>
                            </dl>
                            <dl class="cl permission-list2">
                                <dt>
                                    <label class="">
                                        操作项
                                    </label>
                                </dt>
                                <dd>
                                    <template v-for="(citem,cindex) in levelList(index,4)">
                                        <label class="">
                                            <input type="checkbox" v-model="citem.checked" :value="citem.id" name="menu[]">
                                            {{citem.title}}
                                        </label>
                                    </template>
                                </dd>
                            </dl>
                        </dd>
                    </dl>
                </template>
                
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <a onclick="submit()" class="btn btn-success radius"><i class="icon-ok"></i> 确定</a>
            </div>
        </div>
    </form>
</article>
<script src="//cdn.bootcss.com/vue/2.4.2/vue.min.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            menus: JSON.parse('<?=$menus?>'),
        },
        created: function () {
        },
        watch:{
            menus:{
                deep:true,
                handler:function(val){
                    var self = this;
                    for(var i=0;i<val.length;i++) {
                        for(var j=0;j<val[i].menus.length;j++) {
                            if(val[i]['menus'][j].checked && !val[i].checked) {
                                self.menus[i].checked = 1;
                            }
                        }
                    }
                    
                }
            }
        },
        methods: {
            selectSub:function(item){
                console.log(item);
            },
            levelList:function(index,level){
                var list  = [];
                if(level==4) {
                    for(var i=0;i<this.menus[index].menus.length;i++) {
                        if(this.menus[index].menus[i].level==4){
                            list.push(this.menus[index].menus[i]);
                        }
                    }
                }else{
                    for(var i=0;i<this.menus[index].menus.length;i++) {
                        if(this.menus[index].menus[i].level!=4){
                            list.push(this.menus[index].menus[i]);
                        }
                    }
                }
                return list;
            }
         }
    });
   function submit () {
        $('#form').ajaxSubmit(function(res){
            if(res.ret==0) {
                layer.open({
                    content:res.message,
                    yes:function(){
                        layer.closeAll();
                        parent.location.reload();
                    }
                });
            }else{
                layer.msg(res.message);
            }
        });
    }
</script>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="/static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/hui/h-ui/js/H-ui.js"></script> 
<script type="text/javascript" src="/static/hui/h-ui.admin/js/H-ui.admin.page.js"></script> 
<script type="text/javascript" src="/static/common.js"></script> 
</body>
</html>